/*
 * MAIN ENTRY POINT
 */
$(function(){
	onDeviceReady();
});

function onDeviceReady(){
	selectLanguage();
	H5.init();
	H5.PageLoader.setPath("content/page/");
	H5.PageLoader.load("Creator", null);
};

function selectLanguage(){
	/* Set browser language as page language */
	if(window.navigator){
		if(window.navigator.userLanguage){
			H5.Locale.setLocale(window.navigator.userLanguage);
		} else if(window.navigator.language){
			H5.Locale.setLocale(window.navigator.language);
		}
	}
	
	/* Check local storage for language definition */
	if(H5.Storage.get("lng")){
		H5.Locale.setLocale(H5.Storage.get("lng"));
	}
	
	/* Check get parameter for language definition */
	if(H5.getUrlParam("lng")){
		H5.Locale.setLocale(H5.getUrlParam("lng"));
	}
	
	/* Store selected language */
	H5.Storage.set("lng", H5.Locale.getLocale());
};